package net.liteheaven.xblib.plugin;

import android.content.Context;

import java.nio.file.Path;

public class PluginKit {

    private static PluginKit instance;
    private XPluginManager manager;
    private Context context;

    public static PluginKit getInstance(){
        if (instance == null){
            instance = new PluginKit();
        }
        return instance;
    }

    private PluginKit(){
        manager = new XPluginManager();
    }

    public boolean init(Context context){
        if (context == null){
            throw new IllegalArgumentException("context cannot be null.");
        }
        this.context = context.getApplicationContext();

        XPluginLog.i("PluginKit init");

        String inner = PathUtil.getInnerApkPath("");
        XPluginLog.i("inner = " + inner);

        String external = PathUtil.getExternalApkPath("");
        XPluginLog.i("external = " + external);

        return PluginUtil.hookInstrumentation();
    }

    public void setContext(Context context){
        this.context = context;
    }

    public IntentHandler getIntentHandler(){
        return new IntentHandlerImpl();
    }

    public XPluginManager getManager() {
        return manager;
    }

    Context getContext(){
        return context;
    }
}
